package org.openems.entity;

public class Numeric2Entity extends NumericEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -249107639484242709L;

	public void setBaseValue(Double value) throws InvalidValueException {
		super.setValue(value);
	}
	
	public Double getMagnification() {
		return magnification;
	}

	public void setMagnification(Double magnification) {
		this.magnification = magnification;

	}

	@Override
	public Double getValue() {
		return super.getValue() * this.magnification;
	}

	@Override
	public void setValue(Double value) {
		super.setValue(value / this.magnification);
	}

	@Override
	public String getValueText() {
		return String.format("%." + this.getDecimal().toString() +"f", this.getValue());
	}

	@Override
	public void setValueText(String text) throws InvalidValueException {
		Double value = Double.valueOf(text);
		super.setValue(value / this.magnification);
	}

	public Numeric2Entity(Key key, String name, int decimal, Unit unit,
			Double min, Double max, boolean persisted) {
		super(key, name, decimal, unit, min, max, persisted);
		// TODO Auto-generated constructor stub
	}

	public Numeric2Entity(Key key, String name, Unit unit, Double min,
			Double max, boolean persisted) {
		super(key, name, unit, min, max, persisted);
		// TODO Auto-generated constructor stub
	}

	private Double magnification = 1.0;
}
